package com.ms.service.module.zone.db;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.Session;

import com.xpec.c4.db.basic.BasicGameDAO;
import com.xpec.c4.db.hibernate.manager.HibernateManager;

public class GameJackPotDAO extends BasicGameDAO{
	private static final Log log = LogFactory.getLog(GameJackPotDAO.class);
	
	/**
	 * 讀取遊戲類別全館彩金資料
	 * @param GameType
	 * @return
	 */
	public static GameJackPotDataModel  getGameJackPotData(String GameType , String halltype)
	{
		if(GameType==null)
		{
			log.error("JackPot Module GameType:" + GameType +" not exists!!!!");
			return null;
		}
		
		Session session  = HibernateManager.getSession();
		Query query = session.createQuery("from GameJackPotDataModel Where GameType=:GAMETYPE  and halltype=:HALLTYPE");
		query.setString("GAMETYPE", GameType); 
		query.setString("HALLTYPE", halltype);
		GameJackPotDataModel model = (GameJackPotDataModel) query.uniqueResult();
		return model;
	}
	
	/**
	 * 讀取全部遊戲jp
	 * @param GameType
	 * @return
	 */
	public static List<GameJackPotDataModel> getGameJackPotMoney()
	{
		Session session  = HibernateManager.getSession();
		session.clear();
		Query query = session.createQuery("from GameJackPotDataModel");
		return query.list();
	}
	
	
	
	/**
	 * 創建遊戲各館全館彩金資料
	 * @param model
	 * @return
	 */
	public static boolean createJackPotData(GameJackPotDataModel model)
	{
		HibernateManager.txBegin();
		save(model);
		return HibernateManager.txCommitFailRollbackClearSession();
	}
	
	/**
	 * 更新全館彩金資料
	 * @param model
	 * @return
	 */
	public static boolean modifyJackPotData(GameJackPotDataModel model)
	{
		HibernateManager.txBegin();
		save(model);
		return HibernateManager.txCommitFailRollbackClearSession();
	}
}
